package com.xydtech.ecard.merchant.controller;

import com.xydtech.common.annotation.Log;
import com.xydtech.common.core.controller.BaseController;
import com.xydtech.common.core.domain.AjaxResult;
import com.xydtech.common.core.page.TableDataInfo;
import com.xydtech.common.enums.BusinessType;
import com.xydtech.common.utils.poi.ExcelUtil;
import com.xydtech.ecard.merchant.domain.EcardEmployeeStatistics;
import com.xydtech.ecard.merchant.service.IEcardEmployeeStatisticsService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * <dd>描述: ~ 员工统计列表信息Controller</dd>
 * <dd>创建时间：  14:18 2024/3/12</dd>
 * <dd>创建人： yuzhiguo</dd>
 * <dt>版本历史: </dt>
 * Date         Author         Version     Description
 * ------------------------------------------------------------------
 * 2024/3/12     yuzhiguo         1.0        1.0 Version
 */
@Controller
@RequestMapping("/merchant/employeeStatistics")
public class EcardEmployeeStatisticsController extends BaseController {
    @Autowired
    private IEcardEmployeeStatisticsService ecardEmployeeStatisticsService;

    private String prefix = "merchant";

    @RequiresPermissions("merchant:employeeStatistics:view")
    @GetMapping()
    public String merchant()
    {
        return prefix + "/employeeStatistics";
    }

    /**
     * 查询员工统计列表信息
     * @param ecardEmployeeStatistics
     * @return
     */
    @RequiresPermissions("merchant:employeeStatistics:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(EcardEmployeeStatistics ecardEmployeeStatistics) {
        String salt = getSalt();//盐值
        startPage();
        List<EcardEmployeeStatistics> list = ecardEmployeeStatisticsService.selectEmployeeStatistics(ecardEmployeeStatistics, salt);
        return getDataTable(list);
    }

    @RequiresPermissions("merchant:employeeStatistics:export")
    @Log(title = "导出员工统计列表信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(EcardEmployeeStatistics ecardEmployeeStatistics)
    {
        String salt = getSalt();//盐值
        List<EcardEmployeeStatistics> list = ecardEmployeeStatisticsService.selectEmployeeStatistics(ecardEmployeeStatistics, salt);
        ExcelUtil<EcardEmployeeStatistics> util = new ExcelUtil<EcardEmployeeStatistics>(EcardEmployeeStatistics.class);
        return util.exportExcel(list, "导出员工统计列表信息");
    }
}
